package day2;

/**
 * ClassName：Test5
 *
 * @Author：小鱼
 * @Create：2025-08-19 14:05
 */
public class Test5 {
    //线程优先级
    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run(){
                for (int i = 0; i < 10000000; i++) {
                    if(i%5000==0){
                        System.out.println("i1: "+i);
                    }

                }
            }
        };
        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000000; i++) {
                    if(i%5000==0){
                        System.out.println("i2: "+i);
                    }

                }
            }
        });
        //修改优先级
        thread2.setPriority(Thread.MAX_PRIORITY);
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
        System.out.println("1的优先级"+thread.getPriority());
        thread2.start();
        System.out.println("2的优先级"+thread2.getPriority());

    }
}
